//
//  HJDNumberViewController.m
//  JYHospital
//
//  Created by 胡金东 on 16/5/13.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDNumberViewController.h"
#import "KACircleProgressView.h"


@interface HJDNumberViewController ()<UIScrollViewDelegate>

@property (nonatomic,assign) NSInteger i ;
@property (nonatomic,assign) float  m;
@property (nonatomic,strong) UILabel * lbl;
@property (nonatomic,strong) KACircleProgressView *progress;

//整体页面
@property (nonatomic,strong)UIScrollView *scroll;

@end

@implementation HJDNumberViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"数胎动";
 
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor getColorWithHexNumber:@"848484"]}];

    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(shareBtnClick) image:@"矢量智能对象" HighImage:nil];
    
    self.scroll = [[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.scroll.delegate = self;
    
    self.automaticallyAdjustsScrollViewInsets = YES;
    self.scroll.showsVerticalScrollIndicator = YES;//垂直移动
    self.scroll.showsHorizontalScrollIndicator = NO;//水平移动
    //上下滑动
    self.scroll.contentSize = CGSizeMake(HJDWidth,620 ) ;
    
    
    [self.view addSubview: self.scroll];
    
    
    CGFloat lblX = 0 ;
    CGFloat lblY = 0 ;
    CGFloat lblW = HJDWidth;
    CGFloat lblH = 40;
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(lblX, lblY, lblW, lblH)];
    label.backgroundColor = [UIColor getColorWithHexNumber:@"F1F1EE"];
    label.text = @"  点击数一数今日胎动数，为您预测宝宝健康值";
    label.font = [UIFont systemFontOfSize:14];
    label.textColor = [UIColor getColorWithHexNumber:@"CFCFCF"];
   
    [self.scroll addSubview:label];
    
    CGFloat X = HJDHorizontalMargin/2;
    CGFloat Y = 70;
    CGFloat W = HJDWidth - HJDHorizontalMargin * 2;
    CGFloat H = W;
    self.progress = [[KACircleProgressView alloc] initWithFrame:CGRectMake(X, Y, W, H)];
    [self.scroll addSubview:self.progress];
    self.progress.trackColor = [UIColor getColorWithHexNumber:@"F2F2F2"];
    self.progress.progressColor = [UIColor getColorWithHexNumber:@"5CC5AC"];
    self.progress.progress = 0.00;
    self.progress.progressWidth = 30;

    
    
    
    self.i = 0;
    self.m = 0.00;
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(50, 170, W- 60, W -60)];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [btn setRadius:(W-60)/2 borderWith:0 borderColor:nil];
    [btn setBackgroundColor:[UIColor redColor]];
    [self.scroll addSubview:btn];
    
    
    [self setUplbl];
    
    [self setUpRecord];
    

}

-(void)shareBtnClick
{
    NSLog(@"分享");
}

-(void)btnClick
{
    self.i+= 1;
    self.m +=0.01;

    self.progress.progress += 0.01;
    if (self.i>100) {
        self.lbl.text = @"100";
    }else{
        self.lbl.text = [NSString stringWithFormat:@"%ld",(long)self.i];
    }
}


-(void)setUplbl
{
    
    UIView *sum = [[UIView alloc]initWithFrame:CGRectMake(HJDWidth - 56 - 10, 64, 112/2, 71/2)];
    UIImage *img = [UIImage imageNamed:@"计数心"];
    [sum setBackgroundColor:[UIColor colorWithPatternImage:img]];
    [self.scroll addSubview:sum];
    
    self.lbl = [[UILabel alloc]initWithFrame:CGRectMake(5, 8, 30, 20)];
    self.lbl.textAlignment = NSTextAlignmentCenter;
    self.lbl.font = [UIFont systemFontOfSize:15];
    self.lbl.textColor = [UIColor whiteColor];
       [sum addSubview:self.lbl];
    
}

-(void)setUpRecord
{
    UIButton *record = [[UIButton alloc]initWithFrame:CGRectMake(HJDWidth/2 -100 ,CGRectGetMaxY(self.progress.frame) + 130, 200, 30)];
    [record setTitle:@"查看胎动记录" forState:UIControlStateNormal];
    [record setTitleColor:[UIColor getColorWithHexNumber:@"323232"] forState:UIControlStateNormal];
    [record addTarget:self action:@selector(recordClick) forControlEvents:UIControlEventTouchUpInside];
    [self.scroll addSubview:record];
}

-(void)recordClick
{
    
}

@end
